<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    :destroyOnClose="true"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-row :gutter="15">
        <a-col :md="7" :sm="24">
            <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
              <a-button type="primary" icon="import">导入</a-button>
            </a-upload>
            <div>
              <a :href='url.exportUrl'>行政区划批量导入模板下载</a>
            </div>
        </a-col>
      </a-row>
    </a-spin>
  </j-modal>
</template>

<script>

  import { httpAction,getAction,downFile } from '@/api/manage'
  import pick from 'lodash.pick'
  import { validateDuplicateValue } from '@/utils/util'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JTreeSelect from '@/components/ksource/JTreeSelect'
  export default {
    name: "SysDistrictModal",
    mixins:[JeecgListMixin],
    components: {
      JTreeSelect,
    },
    data () {
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:800,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        url: {
          add: "/platform/system/sysDistrict/add",
          edit: "/platform/system/sysDistrict/edit",
          exportUrl:window._CONFIG['domianURL']+'/platform/system/sysDistrict/exportExcel',
          importExcelUrl: "/platform/system/sysDistrict/importExcel"
        },
      }
    },
    created () {
    },
    computed: {
      importExcelUrl(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      add (obj) {
        this.edit(obj);
      },
      edit () {
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      exportExcel(){
        downFile(this.url.exportUrl).then((data)=>{
          if (!data) {
            this.$message.warning("文件下载失败")
            return
          }
        })
      },
      handleOk () {
        const that = this;
      },
      handleCancel () {
        this.close()
      },

    }
  }
</script>